/**
 * 页面位置
 * @author luguoxiang
 * @date 2023-03-19
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
import { IConfigSchema, LgUploadProps } from '@/soar';
import { basePath } from './api';
import { basePath as contentPath } from './content/api';
import { MenuComponent } from '@/types/interface';

const fieldList: IConfigSchema<any>[] = [
  {
    field: 'code',
    label: '位置编码',
    dataType: 'string',
    form: {
      formItemProps: {
        help: '用于前端读取对应配置内容，比如广告位、轮播图等',
      },
    },
  },
  {
    field: 'name',
    label: '名称',
    dataType: 'string',
  },
  {
    field: 'width',
    label: '宽度',
    dataType: 'number',
    form: {
      formItemProps: {
        help: '通过宽高知道内容封面图的尺寸',
      },
    },
  },
  {
    field: 'height',
    label: '高度',
    dataType: 'number',
    form: {
      formItemProps: {
        help: '通过宽高知道内容封面图的尺寸',
      },
    },
  },
  {
    field: 'description',
    label: '描述',
    dataType: 'string',
    form: {
      component: 't-textarea',
    },
  },
  {
    field: 'imgs',
    label: '位置截图',
    dataType: 'img',
    params: 'default' as LgUploadProps['valueType'],
    table: false,
    search: false,
    form: {
      formItemProps: {
        help: '通过截图清晰的知道具体所在位置',
      },
    },
  },
];

export default fieldList;

/**
 * 组件配置（用于生成菜单数据）
 */
export const COMPONENTS: MenuComponent[] = [
  {
    title: '网站元素',
    component: () => import('./List.vue'),
    sort: 20,
    keepalive: true,
    icon: 'creditcard',
    permits: [`GET${basePath}/query`, `GET${contentPath}/query`],
    elements: [
      { title: '新增', code: 'create', permits: [`POST/${basePath}/create`, `POST/${contentPath}/create`] },
      {
        title: '更新',
        code: 'update',
        permits: [
          `POST/${basePath}/update`,
          `POST/${contentPath}/update`,
          `POST/${basePath}/detail`,
          `POST/${contentPath}/detail`,
        ],
      },
      { title: '删除', code: 'remove', permits: [`POST/${basePath}/remove`, `POST/${contentPath}/remove`] },
      { title: '详情', code: 'detail', permits: [`GET${basePath}/detail`, `GET${contentPath}/detail`] },
      { title: '导入', code: 'import', permits: [`POST/${basePath}/import`, `POST/${contentPath}/import`] },
      { title: '导出', code: 'export', permits: [`GET${basePath}/export`, `GET${contentPath}/export`] },
    ],
  },
];
